See Also

Tcp Class  | Tcp Members  | Overload List

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

Language

Visual Basic

C#

C++

C++/CLI

Show All

buffer
Destination memory location to store received data.
See Also Languages PowerTCP Email Validation for .NET

Receive(Byte[]) Method

Dart.PowerTCP.EmailValidation Namespace > Tcp Class > Receive Method : Receive(Byte[]) Method

Receive data from the host.

[Visual Basic]
<DescriptionAttribute("Receive data into your buffer.")> Overloads Public Function Receive( _    ByVal buffer() As Byte _ ) As Segment
[C#]
[DescriptionAttribute("Receive data into your buffer.")] public Segment Receive(    byte[] buffer );
[C++]
[DescriptionAttribute("Receive data into your buffer.")] public: Segment* Receive(    byte[]* buffer )
[C++/CLI]
[DescriptionAttribute("Receive data into your buffer.")] public: Segment^ Receive(    bytearray<buffer>^ buffer )

Parameters

buffer
Destination memory location to store received data.

Return Type

A Segment object encapsulating the data received.

Exceptions

ExceptionDescription
IOExceptionThe stream is not Readable.
ArgumentNullExceptionbuffer is null.
ArgumentOutOfRangeExceptionoffset or count is less than 0.
ArgumentExceptionoffset + count is greater than the length of buffer.
SocketExceptionThe socket is not connected.

Remarks

After connecting, data can be received using the Tcp.Recieve method. All Tcp.Receive methods return a Segment object, encapsulating the data received. In order to access the data, simply access the properties of the Segment object returned such as Segment.Buffer (to access the data in a byte array) or Segment.ToString (to access the data as a string).

If the amount of data received from the server exceeds Tcp.ReceiveBufferSize, the Tcp.Receive method will have to be called multiple times until the socket closes.

This method is functionally equivalent to Tcp.Stream.Write(byte[]).

Example

The following example demonstrates sending bytes to the server.

[Visual Basic] 

Private Sub Test()
   ' Connect to an echo port
   Tcp1.Connect("atropos", 7)

   Dim sendbuffer() As Byte = System.Text.Encoding.Default.GetBytes("abcdefg")

   ' Send some bytes.
   Tcp1.Send(sendbuffer)

   Dim recvbuffer(sendbuffer.Length) As Byte

   ' Server will echo the bytes back. Receive the bytes.
   Tcp1.Receive(recvbuffer)

   ' Close the connection.
   Tcp1.Close()
End Sub

[C#] 


private void Test()
{
  
// Connect to the echo port
  
tcp1.Connect("atropos", 7);

  
byte[] sendbuffer = System.Text.Encoding.Default.GetBytes("abcdefg");

  
// Send some bytes.
  
tcp1.Send(sendbuffer);

  
byte[] recvbuffer = new byte[sendbuffer.Length];

  
// Server will echo the bytes back. Receive the bytes.
  
tcp1.Receive(recvbuffer);

  
// Close the connection.
  
tcp1.Close();
}
                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

See Also

Tcp Class  | Tcp Members  | Overload List


Send comments on this topic.

Documentation version 1.0.3.0.

© 2008 Dart Communications.  All rights reserved.